<template>
	<view>
		<!-- 头部搜索框 -->
		<search :placeholder="$t('public.productionNo')" />
		<zy-table :headList="headList" :dataList="dataList" line @lineClick="lineClick" border>
		</zy-table>
		<zy-popup ref="zyPopup" type='dialog' @confirm="confirm" :title="$t('public.detail')">
			<scroll-view scroll-y="true" style="height:45vh">
				<zy-forms :model="formData" border labelWidth="160">
					<zy-form-item :label="$t('public.productionNo')+$t('public.colon')"><text
							class="formText">{{formData.productionNo || $t('public.null')}}</text>
					</zy-form-item>
					<zy-form-item :label="$t('homepage.ProductionPick.productionOrder')+$t('public.colon')"><text
							class="formText">{{formData.saleOrderNo || $t('public.null')}}</text>
					</zy-form-item>
					<zy-form-item :label="$t('public.materialName')+$t('public.colon')"><text
							class="formText">{{formData.materialName || $t('public.null')}}</text>
					</zy-form-item>
					<zy-form-item :label="$t('public.materialSpec')+$t('public.colon')"><text
							class="formText">{{formData.materialSpec || $t('public.null')}}</text>
					</zy-form-item>
					<zy-form-item :label="$t('public.clothWidth')+$t('public.colon')"><text
							class="formText">{{formData.clothWidth || $t('public.null')}}</text>
					</zy-form-item>
					<zy-form-item :label="$t('public.color')+$t('public.colon')"><text
							class="formText">{{formData.color || $t('public.null')}}</text></zy-form-item>
					<zy-form-item :label="$t('public.pattern')+$t('public.colon')"><text
							class="formText">{{formData.pattern || $t('public.null')}}</text></zy-form-item>
				</zy-forms>
			</scroll-view>
		</zy-popup>
	</view>
</template>

<script>
	import {
		queryListMap
	} from "@/api/homepage.js"
	export default {
		data() {
			return {
				//生产单列表表格表头
				headList: [{
					name: this.$t('public.productionNo'),
					key: 'productionNo',
					width: '100'
				}, {
					name: this.$t('homepage.ProductionPick.productionOrder'),
					key: 'saleOrderNo',
					width: '100'
				}, {
					name: this.$t('public.materialName'),
					key: 'materialName',
					width: '100'
				}, {
					name: this.$t('public.materialSpec'),
					key: 'materialSpec',
					width: '100'
				}, {
					name: this.$t('public.clothWidth'),
					key: 'clothWidth',
					width: '100'
				}, {
					name: this.$t('public.color'),
					key: 'color',
					width: '100'
				}, {
					name: this.$t('public.pattern'),
					key: 'pattern',
					width: '100'
				}],
				dataList: [], //生产单列表表格数据,
				//“详情”表单字段
				formData: {
					saleOrderNo: '',
					materialName: '',
					materialSpec: '',
					clothWidth: '',
					color: '',
					pattern: '',
				},
			}
		},
		// 下拉刷新
		onPullDownRefresh() {
			setTimeout(function() {
				uni.redirectTo({
					url: "/pages/HomePage/ProductionPick/list"
				})
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onLoad() {
			var _this = this
			uni.$on('scancodechilddate', function(data) {
				_this.searchList(data.code)
			})
		},
		onUnload() {
			// 移除监听事件 
			uni.$off('scancodechilddate')
		},
		methods: {
			//获取生产单列表
			searchList(e) {
				this.dataList = []
				queryListMap({
					// productionType: "1",
					productionNo: e,
					status: '0'
				}).then((res) => {
					if (res.code == 0) {
						this.dataList = res.data
					} else {
						uni.showToast({
							title: res.message,
							icon: "none",
							duration: 3000
						})
					}
				}).catch((res) => {
					uni.showToast({
						title: res.message,
						icon: "none",
						duration: 3000
					})
				});
			},
			//生产单列表选择
			lineClick(e) {
				this.$refs.zyPopup.open()
				this.formData = e.value
			},
			cancel() {
				this.$refs.zyPopup.close()
			},
			confirm() {
				uni.$emit('formData', this.formData)
				uni.navigateBack({
					delta: 1
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.formText {
		color: #999;
	}
</style>